# negative 2 positive
import numpy as np

def neg2post(mat):
    r, c = mat.shape
    for idxr in range(r):
        for idxc in range(c):
            if mat[idxr, idxc] <= 0:
                mat[idxr, idxc] = np.mean(mat[idxr-1:idxr+2, idxc-1:idxc+2])
            if np.isnan(mat[idxr, idxc]):
               mat[idxr, idxc] = 0
    return mat

